package chapter02

/**
 * @program lu-scala01
 * @description:
 * @author: zhanglu
 * @create: 2022-02-11 11:01:00
 */
object C01_CharacterString {

  def main(args: Array[String]): Unit = {
    val age = 18.446
    val name = "lu"
    var rs = name + " -> " + age
    println(rs)
    printf("%s -> %f", name, age)
    println()
    printf("%s -> %4.2f", name, age)
    println()
    rs = s"${name} -> ${age}" //模版输出 类似于shell
    println(rs)
    rs = f"${name} -> ${age}%4.2f"  //模版 识别符号输出
    println(rs)
    rs = raw"${name} -> ${age}%4.2f"  //原样输出
    println(rs)
    //保持多行字符串的原格式输出 ｜顶个输出
    rs =
      """
         |select
         |*
         |from student
         |where name=${name} and age=${age}
         |""".stripMargin
    println(rs)
    rs =
      s"""
         |select
         |*
         |from student
         |where name=${name} and age=${age}
         |""".stripMargin
    println(rs)
    rs =
      f"""
         |select
         |*
         |from student
         |where name=${name} and age=${age}%4.2f
         |""".stripMargin
    println(rs)
  }

}
